<%@ taglib uri="/WEB-INF/myfaces_html.tld" 	prefix="h" %>
<%@ taglib uri="/WEB-INF/myfaces_core.tld" 	prefix="f" %>
<%@ taglib uri="/WEB-INF/tomahawk.tld"     	prefix="t" %>
<%@ page import="it.azienda.framework.utilita.Utilita" %>
<%@ page import="it.azienda.managerworkstandard.modello.BeanFornitore" %>
<%@ page import="java.util.*" %>    
<%@ page import="javax.faces.context.FacesContext" %>
<%
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(FacesContext.getCurrentInstance().getApplication().getMessageBundle(), FacesContext.getCurrentInstance().getApplication().getDefaultLocale());
    String versioneSw=bundle.getString("managerwork_titolo");
%>    

<%  
    String lookup=(String)request.getParameter("lookup");
    if(lookup==null && Utilita.getSession().getAttribute("lookup")!=null){
        lookup=(String)session.getAttribute("lookup");
        session.setAttribute("lookup",lookup);
    }else{
        session.setAttribute("lookup",lookup);
    }
%>      
            
    <f:view>   
        <html lang="it">
            <head>
                <title><%=versioneSw%> - Lookup Fornitori</title>   
                <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
                <link rel="stylesheet" href="../managerwork.css" type="text/css">
            </head>        
            <body>                
                <h:form id="uno">
                    <table class="lookUp">
                        <tr>     
                            <td class="etichettaIntestazioneLookUp" colspan="5" align="center"><strong><t:outputLabel for="ricerca" value="Modulo di Ricerca Fornitori" /></strong></td>                        
                        </tr>     

                        <tr>     
                            <td class="lookUptd"><strong><t:outputLabel for="prop1" value="Ragione Sociale:" /></strong></td>            
                            <td><t:inputText id="prop1" value="#{beanFind.prop1}" size="30" maxlength="30" styleClass="viewEtichetta" onchange="this.value=this.value.toUpperCase()" /></td>
                        </tr>                 
 
                        <tr>     
                            <td class="lookUptd"><strong><t:outputLabel for="prop2" value="Comune Residenza:" /></strong></td>            
                            <td><t:inputText id="prop2" value="#{beanFind.prop2}" size="30" maxlength="30" styleClass="viewEtichetta" onchange="this.value=this.value.toUpperCase()" /></td>
                        </tr>                 

                        <t:inputHidden id="tabella" value="fornitori" />                    
                        <t:inputHidden id="bean" value="BeanFornitore" />                    
                        <t:inputHidden id="proprieta" value="ragioneSociale,tableComuni-BeanComune-descrizione-comuneResidenza_id"/>         
                
                        <tr>
                            <td>
                                <t:commandButton value="Invia" actionListener="#{dettaglioFornitore.cercaOggettiLookup}" immediate="true" >                         
                                </t:commandButton>                       
                            </td>                              
                            <td>
                                <t:commandButton value="Chiudi" action="#{dettaglioFornitore.resettaLookup}" onclick="javascript:window.close()" immediate="true" >                         
                                </t:commandButton>                       
                            </td>                                                 
                        </tr>                
                    </table>
                </h:form>   

        
                <h:form id="erroriDataBase" rendered="false">
                    <td align="left" class="messaggiErrore" height="2px">           
                        <h:messages  style="color: red" showDetail="true" showSummary="false"/>
                    </td>
                </h:form>   
    
                <h:form >
                    <div  style="overflow: scroll; height: 150px; white-space: nowrap; wrap: off">
                        <t:dataTable id="tabella2" var="lista" value="#{listaLookup}" preserveDataModel="true"           
                            styleClass="dataTableGestisci_TableLookUp" 
                            headerClass="dataTableGestisci_HeaderLookUp"
                            rowClasses="dataTableGestisci_Row1LookUp, dataTableGestisci_Row2LookUp"          
                            columnClasses="dataTableGestisci_ColumnLookUp" 
                            rowOnMouseOver="this.style.backgroundColor='#FFCC00'"
                            rowOnMouseOut="this.style.backgroundColor=''">
                
                            <t:column width="10%">
                                <f:facet name="header"  >
                                    <t:outputText value="Codice" />
                                </f:facet>
                                <t:outputText value="#{lista.codice}" /> 
                            </t:column>
                            
                            <t:column width="10%">
                                <f:facet name="header"  >
                                    <t:outputText value="Ragione Sociale" />
                                </f:facet>
                                <t:outputText value="#{lista.ragioneSociale}" /> 
                            </t:column>                    
                         
                            <t:column width="10%">
                                <f:facet name="header"  >
                                    <t:outputText value="Categoria" />
                                </f:facet>
                                <t:outputText value="#{lista.beanCategoriaFor.descrizione}" /> 
                            </t:column>
                    
                            <t:column width="1%">
                                <t:inputHidden id="idLookup" value="#{lista.id}" /> 
                            </t:column>
                    
                         
                            <t:column width="10%">
                                <t:commandButton value="INVIA" action="#{dettaglioFornitore.resettaLookup}" onclick="valorizeOpener('ragioneSocialeFornitore','#{lista.ragioneSocialeFind}')" immediate="true">                                                         
                                </t:commandButton>    
                            </t:column>       
                        </t:dataTable>  
                    </div>
                </h:form>       

                <script type="text/javascript">
                    function valorizeOpener(lookup,descComune)
                    {
                    propLookup='formLookup:' + lookup;
                    window.opener.document.getElementById(propLookup).focus()
                    window.opener.document.getElementById(propLookup).value=descComune
                    window.opener.document.formLookup.submit()
                    window.close()
                    }
                </script>
            </body>
        </html>
    </f:view>
